linearizeEncodings.js ➔ linearizeEncodings   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A linearizeEncodings.js ➔ ... ➔ nextLevel 0 12 3
1
export default linearizeEncodings;
2
3
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
4
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
5
function linearizeEncodings(encodings){
6
	var linearEncodings = [];
7
	function nextLevel(encoded){
8
		if(Array.isArray(encoded)){
9
			for(let i = 0; i < encoded.length; i++){
10
				nextLevel(encoded[i]);
11
			}
12
		}
13
		else{
14
			encoded.text = encoded.text || "";
15
			encoded.data = encoded.data || "";
16
			linearEncodings.push(encoded);
17
		}
18
	}
19
	nextLevel(encodings);
20
21
	return linearEncodings;
22
}
23